import proto from '../proto/ProtoMsgV1_pb.js';
import ProtobufEncoder from '../code/ProtobufEncoder.js';

const LoginMsgBuilder = {
	build: function(appId, userId, imei, token) {		
		// 原消息
		let protoObj = new proto.Message();
		protoObj.setType(proto.HeadType.LOGIN_REQUEST);
		protoObj.setSequence(1);
		protoObj.setSessionId("-1");
		protoObj.setAppId(appId)
		let loginRequest = new proto.LoginRequest();
		loginRequest.setUid(userId);
		loginRequest.setDeviceId(imei);
		loginRequest.setToken(token);
		loginRequest.setPlatformType(proto.PlatformType.WEB);
		loginRequest.setAppVersion("1.0.0-test");
		protoObj.setLoginRequest(loginRequest);
		
		const encode = ProtobufEncoder.encode(protoObj);
		
		return encode;
	}
}

export default LoginMsgBuilder;